import { Text, StyleSheet } from "react-native";
import type { IconProps } from "react-native-vector-icons/Icon";
import theme from "@/styles/theme";
import CustomIcon from "@/components/CustomIcon";

export type Props = {
  /**
   * icon 类型
   */
  type?: "warning" | "error" | "success" | "info" | "";

  /**
   * icon 样式
   */
  // iconStyle?: StyleProp<TextStyle>;
  iconStyle?: IconProps["style"];
};

const FontIcon = (props: Props) => {
  let iconComp;

  switch (props.type) {
    case "warning":
      iconComp = <CustomIcon name="icon-jinggao1" style={[styles.icon, { color: theme.warn }, props.iconStyle]} />;
      break;
    case "error":
      iconComp = <CustomIcon name="icon-cuowu1" style={[styles.icon, { color: theme.danger }, props.iconStyle]} />;
      break;
    case "success":
      iconComp = (
        <CustomIcon name="icon-chenggong" style={[styles.icon, { color: theme.success, fontSize: 18 }, props.iconStyle]} />
      );
      break;
    case "info":
      iconComp = <CustomIcon name="icon-guanyuwomen" style={[styles.icon, { color: theme.info, fontSize: 18 }, props.iconStyle]} />;
      break;
    default:
      iconComp = <Text></Text>;
      break;
  }

  return iconComp;
};

const styles = StyleSheet.create({
  icon: {
    fontSize: 20,
    marginRight: 4
  }
});

export default FontIcon;
